home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1674 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  12.1 KB

  1. Subject: Re: some more 110h4 clues...
  2. Date: Sun, 3 Jul 94 12:33:40 CDT
  3. From: Juergen Lock <nox@jelal.north.de>
  4. In-Reply-To: <9406281647.AB00322@pirol.techfak.uni-bielefeld.de>; from "Torsten Scherer" at Jun 28, 94 4:11 pm
  5. Message-Id: <9407031033.AA00399@jelal.north.de>
  6.  
  7. ok i'm back...  some mails i sent got lost but before i resend anything
  8. i have some new diffs.  (please post answers, or use the Reply-To: for now.)
  9.  
  10. Torsten Scherer writes:
  11.  
  12. >  To further specify my last comment:
  13.  
  14.  thanx!  i'm sorry for all the trouble, i still have no '030 to test MMU
  15. stuff myself... :/  i hope i this is better.
  16.  
  17. 1. exec vs. memoryprotection, use parents MMU context in fork_restore;
  18. look for links to the same region in fork and when calculatig process
  19. size and also don't count sleeping fork parents memory twice...
  20.  
  21. Index: dosmem.c
  22. @@ -474,6 +478,7 @@
  23.          char cbuf[128], *tail = ptr2;
  24.          if (overlay) {
  25.              static char fbuf[PATH_MAX];
  26. +            cbuf[127] = 0;
  27.              ptr1 = strncpy (fbuf, ptr1, PATH_MAX-2);
  28.              tail = strncpy (cbuf, ptr2, 127);
  29.          }
  30. @@ -1331,7 +1336,8 @@
  31.          savemem->mflags |= M_FSAVED;
  32.          for (i = 0; i < curproc->num_reg; i++) {
  33.              m = curproc->mem[i];
  34. -            if (m && !(m->mflags & (M_FSAVED|M_SHTEXT))) {
  35. +            if (m && !(m->mflags & (M_SEEN|M_FSAVED|M_SHTEXT))) {
  36. +                m->mflags |= M_SEEN; /* save links only once */
  37.                  if (i != 1 || txtsize == 0) {
  38.                      quickmove(saveplace, (char *)m->loc, m->len);
  39.                      saveplace += m->len;
  40. @@ -1343,6 +1349,10 @@
  41.                  }
  42.              }
  43.          }
  44. +        for (i = 0; i < curproc->num_reg; i++) {
  45. +            if (curproc->mem[i])
  46. +                curproc->mem[i]->mflags &= ~M_SEEN;
  47. +        }
  48.      }
  49.                  
  50.      p->ctxt[CURRENT] = p->ctxt[SYSCALL];
  51. @@ -1399,6 +1409,7 @@
  52.      long txtsize = p->txtsize;
  53.      char *saveplace;
  54.      int i;
  55. +    extern int no_mem_prot;
  56.  
  57.      if (!savemem) {
  58.          for (i = 0; i < p->num_reg; i++) {
  59. @@ -1414,9 +1425,15 @@
  60.      saveplace = (char *)savemem->loc;
  61.  
  62.      TRACE(("do_vfork: parent restoring memory"));
  63. +#if 1
  64. +    if (p != curproc && !no_mem_prot)
  65. +/* memprot doesn't like it?  try p's mmu context... */
  66. +        set_mmu (p->ctxt[CURRENT].crp, p->ctxt[CURRENT].tc);
  67. +#endif
  68.      for (i = 0; i < p->num_reg; i++) {
  69.          m = p->mem[i];
  70. -        if (m && !(m->mflags & (M_FSAVED|M_SHTEXT))) {
  71. +        if (m && !(m->mflags & (M_SEEN|M_FSAVED|M_SHTEXT))) {
  72. +            m->mflags |= M_SEEN;
  73.              if (i != 1 || txtsize == 0) {
  74.                  quickmove((char *)m->loc, saveplace, m->len);
  75.                  saveplace += m->len;
  76. @@ -1428,6 +1445,14 @@
  77.              }
  78.          }
  79.      }
  80. +    for (i = 0; i < p->num_reg; i++) {
  81. +        if (p->mem[i])
  82. +            p->mem[i]->mflags &= ~M_SEEN;
  83. +    }
  84. +#if 1
  85. +    if (p != curproc && !no_mem_prot)
  86. +        set_mmu (curproc->ctxt[CURRENT].crp, curproc->ctxt[CURRENT].tc);
  87. +#endif
  88.      detach_region(p, savemem);
  89.  }
  90.  
  91. Index: mem.c
  92. @@ -407,6 +407,8 @@
  93.      rfreelist = m;
  94.  }
  95.  
  96. +#if 0
  97. +/*notused*/
  98.  /*
  99.   * change_prot_status: change the status of a region to 'newmode'.  We're
  100.   * given its starting address, not its region structure pointer, so we have
  101. @@ -438,6 +440,7 @@
  102.      mark_region(*mr,newmode);
  103.      return E_OK;
  104.  }
  105. +#endif
  106.  
  107.  /*
  108.   * virtaddr
  109. @@ -602,7 +605,9 @@
  110.   * text regions.
  111.   */
  112.      nfirstp = NULL;
  113. +#if 0
  114.  retry:
  115. +#endif
  116.      n = *map;
  117.  retry2:
  118.      s = nlast = NULL;
  119. @@ -1247,14 +1257,16 @@
  120.          for (i = 0; i < execproc->num_reg; i++) {
  121.              m = execproc->mem[i];
  122.              if (m && m->links == 0xfffe) {
  123. +                execproc->mem[i] = 0;
  124. +                execproc->addr[i] = 0;
  125.                  if (m->mflags & M_SHTEXT_T) {
  126. +                    TRACE (("create_base: keeping sticky text segment (%lx, len %lx)",
  127. +                        m->loc, m->len));
  128.                      m->links = 0xffff;
  129.                  } else {
  130.                      m->links = 0;
  131.                      free_region(m);
  132.                  }
  133. -                execproc->mem[i] = 0;
  134. -                execproc->addr[i] = 0;
  135.              }
  136.          }
  137.      }
  138. @@ -1281,7 +1293,7 @@
  139.              if (!s->text) {
  140.                  s->text = m;
  141.                  if (protmode != PROT_P)
  142. -                    change_prot_status (curproc, m->loc, PROT_P);
  143. +                    mark_region(m, PROT_P);
  144.                  m = 0;
  145.              }
  146.          }
  147. @@ -1778,8 +1790,23 @@
  148.              m = p->mem[i];
  149.              if (m) {
  150.                  m->links--;
  151. +#if 1
  152. +                if (m->links <= 0) {
  153. +                    if (!m->links) {
  154. +                        if (m->mflags & M_SHTEXT_T) {
  155. +                            TRACE (("exec_region: keeping sticky text segment (%lx, len %lx)",
  156. +                                m->loc, m->len));
  157. +                            m->links = 0xffff;
  158. +                        } else
  159. +                            free_region(m);
  160. +                    } else
  161. +                        ALERT ("exec_region: region %lx bogus link count %d, not freed (len %lx)",
  162. +                            m->loc, m->links, m->len);
  163. +                }
  164. +#else
  165.                  if (m->links <= 0)
  166.                      free_region(m);
  167. +#endif
  168.              }
  169.          }
  170.          if (p->num_reg > NUM_REGIONS) {
  171. @@ -1899,8 +1926,16 @@
  172.  
  173.      size = 0;
  174.      for (i = 0; i < p->num_reg; i++) {
  175. -        if (p->mem[i])
  176. +        if (p->mem[i]) {
  177. +            if (p->mem[i]->mflags & (M_SEEN|M_FSAVED))
  178. +                continue;    /* count links only once */
  179. +            p->mem[i]->mflags |= M_SEEN;
  180.              size += p->mem[i]->len;
  181. +        }
  182. +    }
  183. +    for (i = 0; i < p->num_reg; i++) {
  184. +        if (p->mem[i])
  185. +            p->mem[i]->mflags &= ~M_SEEN;
  186.      }
  187.      return size;
  188.  }
  189. @@ -2016,8 +2051,8 @@
  190.      FORCE("%s memory dump: starting at region %lx",
  191.          (map == ker ? "ker" : (map == core ? "core" : "alt")), m);
  192.      while (m) {
  193. -        FORCE("%ld bytes at %lx (%d links); next region %lx", m->len, m->loc,
  194. -            m->links, m->next);
  195. +        FORCE("%ld bytes at %lx (%d links, mflags %x); next %lx", m->len, m->loc,
  196. +            m->links, m->mflags, m->next);
  197.          m = m->next;
  198.      }
  199.  #else
  200. Index: mem.h
  201. @@ -28,6 +28,7 @@
  202.  #define M_SHTEXT_T    0x20    /* `sticky bit' for shared text regions */
  203.  #define M_FSAVED    0x40    /* region is saved memory of a forked process */
  204.  #define M_KEEP        0x0100    /* don't free on process termination */
  205. +#define M_SEEN        0x8000    /* for memused() to find links */
  206.  
  207.  /* dummy type for virtual addresses */
  208.  typedef struct vaddr {
  209.  
  210. 2. GEM/toswin memleaks:  only link M_KEEP regions to rootproc when its
  211. the last link, then Mfree still works after a fork.  this was the only
  212. real leak, the rootproc growing and growing mostly was a result of the
  213. process size caculation...
  214.  
  215. Index: dosmem.c
  216. @@ -849,7 +854,7 @@
  217.              curproc->mem[i] = 0; curproc->addr[i] = 0;
  218.              if (m) {
  219.          /* don't free specially allocated memory */
  220. -                if (m->mflags & M_KEEP) {
  221. +                if (m->mflags & M_KEEP && m->links <= 1) {
  222.                      if (curproc != rootproc)
  223.                          attach_region(rootproc, m);
  224.                  }
  225.  
  226. 3. pipe FIONREAD: delay writer-died error condition until pipe is empty.
  227. (can this cause problems?  i think not, and it helps for example toswin,
  228. processes last words no longer appear 1-char-at-a-time...)
  229.  
  230. Index: pipefs.c
  231. @@ -767,14 +767,18 @@
  232.      case FIONREAD:
  233.              p = (f->flags & O_HEAD) ? this->outp : this->inp;
  234.              assert(p != 0);
  235. -            if (p->writers <= 0 || p->writers == VIRGIN_PIPE) {
  236. -                DEBUG(("pipe FIONREAD: no writers"));
  237. +            if (p->writers == VIRGIN_PIPE) {
  238. +                DEBUG(("pipe FIONREAD: no writers yet"));
  239.                  r = -1;
  240.              } else {
  241.                  r = p->tail - p->head;
  242.                  if (r < 0) r += PIPESIZ;
  243.                  if (is_terminal(f))
  244.                      r = r >> 2;    /* r /= 4 */
  245. +                if (!r && p->writers <= 0) {
  246. +                    DEBUG(("pipe FIONREAD: no writers"));
  247. +                    r = -1;
  248. +                }
  249.              }
  250.              *((long *) buf) = r;
  251.              break;
  252.  
  253. 4. sleep: shouldn't we keep the ipl-too-high checks?  it can still happen
  254. outside selects...
  255.  
  256. Index: proc.c
  257. @@ -9,7 +9,7 @@
  258.  #include "mint.h"
  259.  #include "xbra.h"
  260.  
  261. -static void do_wakeup_things P_((void));
  262. +static void do_wakeup_things P_((short sr));
  263.  
  264.  extern short proc_clock;
  265.  
  266. @@ -419,7 +419,8 @@
  267.   */
  268.  
  269.  static void
  270. -do_wakeup_things()
  271. +do_wakeup_things(sr)
  272. +short sr;
  273.  {
  274.  /*
  275.   * check for stack underflow, just in case
  276. @@ -429,31 +430,35 @@
  277.  
  278.      p = curproc;
  279.  
  280. -    if ( p->pid != 0 &&
  281. -         ((long)&foo) < (long)p->stack + ISTKSIZE + 512 ) {
  282. -        ALERT("stack underflow");
  283. -        handle_sig(SIGBUS);
  284. -    }
  285. +    if ((sr & 0x700) < 0x500) {
  286. +/* skip all this if int level is too high */
  287.  
  288. +        if ( p->pid != 0 &&
  289. +             ((long)&foo) < (long)p->stack + ISTKSIZE + 512 ) {
  290. +            ALERT("stack underflow");
  291. +            handle_sig(SIGBUS);
  292. +        }
  293. +
  294.  /* see if process' time limit has been exceeded */
  295.  
  296. -    if (p->maxcpu) {
  297. -        if (p->maxcpu <= p->systime + p->usrtime) {
  298. -            DEBUG(("cpu limit exceeded"));
  299. -            raise(SIGXCPU);
  300. +        if (p->maxcpu) {
  301. +            if (p->maxcpu <= p->systime + p->usrtime) {
  302. +                DEBUG(("cpu limit exceeded"));
  303. +                raise(SIGXCPU);
  304. +            }
  305.          }
  306. -    }
  307.  
  308.  /*
  309.   * check for alarms and similar time out stuff (see timeout.c)
  310.   */
  311.  
  312. -    checkalarms();
  313. -    if (p->sigpending)
  314. -        check_sigs();        /* check for signals */
  315. +        checkalarms();
  316. +        if (p->sigpending)
  317. +            check_sigs();        /* check for signals */
  318. +    }
  319.  
  320.      if (p->slices >= 0) {
  321. -    proc_clock = TIME_SLICE;    /* get a fresh time slice */
  322. +        proc_clock = TIME_SLICE;    /* get a fresh time slice */
  323.      } else {
  324.          proc_clock = -p->slices;    /* slices set by run_next */
  325.          p->curpri = p->pri;
  326. @@ -507,7 +512,7 @@
  327.          (que == READY_Q && !sys_q[READY_Q])) {
  328.  /* we're just going to wake up again right away! */
  329.          spl(sr);
  330. -        do_wakeup_things();
  331. +        do_wakeup_things(sr);
  332.          return (onsigs != curproc->nsigs);
  333.      }
  334.  
  335. @@ -573,7 +578,7 @@
  336.  #endif
  337.              *((void **)0x44eL) = curproc->logbase;
  338.  #endif
  339. -        do_wakeup_things();
  340. +        do_wakeup_things(sr);
  341.          return (onsigs != curproc->nsigs);
  342.      }
  343.  /*
  344.  
  345. 5. some lost tabs, etc. :)
  346.  
  347. Index: biosfs.c
  348. @@ -1388,7 +1388,7 @@
  349.              }
  350.          }
  351.          return 0;
  352. -    }
  353. +        }
  354.      case TIOCOUTQ:
  355.          {
  356.          int oldmap;
  357. @@ -1412,7 +1412,7 @@
  358.           else
  359.              *r = 0;
  360.          return 0;
  361. -    }
  362. +        }
  363.      case TIOCGWINSZ:
  364.          if (f->fc.aux != 2)
  365.            return EINVFN;
  366. Index: dosmem.c
  367. @@ -1176,7 +1181,7 @@
  368.              TRACE(("Pwaitpid(ptracer): returning status to tracing process"));
  369.              p->ptracer = NULL;
  370.              if (p->ppid != -1)
  371. -            return r;
  372. +                return r;
  373.          }
  374.          else {
  375.          /* Hmmm, the real parent got here first */
  376. Index: fasttext.c
  377. @@ -1381,7 +1381,7 @@
  378.          /* avoid collisions with other processes */
  379.              if (tty->rsel)
  380.                  return 2;
  381. -                tty->rsel = p;
  382. +            tty->rsel = p;
  383.          }
  384.          return 0;
  385.      } else if (mode == O_WRONLY) {
  386. Index: proc.c
  387. @@ -291,11 +291,11 @@
  388.  
  389.      for (p = proclist; p; p = p->gl_next) {
  390.          if (p->slices >= 0) {
  391. -        p->curpri = p->pri;
  392. -        p->slices = SLICES(p->curpri);
  393. +            p->curpri = p->pri;
  394. +            p->slices = SLICES(p->curpri);
  395. +        }
  396.      }
  397.  }
  398. -}
  399.  
  400.  /*
  401.   * more priority code stuff:
  402. Index: timeout.c
  403. @@ -216,7 +216,7 @@
  404.  {
  405.      TIMEOUT *cur, **prev;
  406.      short sr = spl7();
  407. -    
  408. +
  409.      prev = &tlist;
  410.      for (cur = tlist; cur; cur = cur->next) {
  411.          if (cur == this && (cur->proc == curproc)) {
  412. Index: tty.c
  413. @@ -691,16 +691,16 @@
  414.  /* we may be in the middle of an escape sequence */
  415.      scan = (tty->state & TS_ESC);
  416.      if (scan != 0) {
  417. -            tab = tty->xkey ? tty->xkey : vt52xkey;
  418. -            r = (unsigned char) tab[scan++];
  419. -            if (r) {
  420. -                c = UNDEF;
  421. -                if (tab[scan] == 0) scan = 0;
  422. -            }
  423. -            else
  424. -                scan = 0;
  425. -            tty->state = (tty->state & ~TS_ESC) | scan;
  426. +        tab = tty->xkey ? tty->xkey : vt52xkey;
  427. +        r = (unsigned char) tab[scan++];
  428. +        if (r) {
  429. +            c = UNDEF;
  430. +            if (tab[scan] == 0) scan = 0;
  431.          }
  432. +        else
  433. +            scan = 0;
  434. +        tty->state = (tty->state & ~TS_ESC) | scan;
  435. +    }
  436.  
  437.      while (c != UNDEF) {
  438.          ret = (*f->dev->read)(f, (char *)&r, 4L);
  439.  
  440. (6. debugging stuff, probably not worth adding to the release...)
  441. btw when i took out this F_KEEP everything i tried worked as before,
  442. anyone knows when its really needed?
  443.  
  444. Index: dosmem.c
  445. @@ -120,7 +120,11 @@
  446.      if (((mode & F_PROTMODE) == 0) &&
  447.          (curproc->ctxt[SYSCALL].pc > 0x00e00000L) &&
  448.          (curproc->ctxt[SYSCALL].pc < 0x00efffffL)) {
  449. +#if 0
  450. +        mode |= (F_PROT_S + 0x10);
  451. +#else
  452.          mode |= (F_PROT_S + 0x10) | F_KEEP;
  453. +#endif
  454.          TRACE(("m_xalloc: VDI special (call from ROM)"));
  455.      }
  456.  /*
  457. Index: main.c
  458. @@ -480,6 +480,7 @@
  459.      int isGEMDOS;
  460.  {
  461.      short save_sr;
  462. +    BASEPAGE *calltosbp;
  463.  
  464.      if (in_kernel) return;
  465.  
  466. @@ -491,10 +492,16 @@
  467.      *((long *) 0x84L) = (long)old_dos.next;
  468.      *((long *) 0xb4L) = (long)old_bios.next;
  469.      *((long *) 0xb8L) = (long)old_xbios.next;
  470. +    calltosbp = *tosbp;
  471.      *tosbp = _base;
  472.  
  473.      in_kernel = 1;
  474.      spl(save_sr);
  475. +#if 1
  476. +    if (isGEMDOS && calltosbp != curproc->base)
  477. +        ALERT("enter_kernel: syscall with tosbp (%lx: %lx) != curproc->base (%lx)",
  478. +            tosbp, calltosbp, curproc->base);
  479. +#endif
  480.  }
  481.  
  482.  /*
  483. Index: mem.c
  484. @@ -1156,6 +1161,11 @@
  485.              for (i = 0; i < parent->num_reg; i++) {
  486.                  m = parent->mem[i];
  487.                  if (m && (m->mflags & M_FSAVED)) {
  488. +#if 1
  489. +                    if (m->links != 1)
  490. +                        ALERT ("create_base: fork parent saved region %lx link count != 1 (%d, len %lx)",
  491. +                            m->loc, m->links, m->len);
  492. +#endif
  493.                      m->links = 0xfffe;
  494.                      savemem = m;
  495.                      break;
  496.  
  497.  oh and yes, i'm still using gcc 2.3.3pl2 too :)
  498.  
  499.  cheers
  500.     Juergen
  501. -- 
  502. J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
  503.                                 ...ohne Gewehr
  504. PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 
  505.